Skip to content

feat(mcpx): supervised stdio by default + adopt-or-reap + restart through supervisor (#9963) - #10767

Merged
dezren39 merged 1 commit into
mainfrom
queue/17484-9963-mcpx-phase3
Nov 16, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/17484-9963-mcpx-phase3

Conversation

@dezren39

@dezren39 dezren39 commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Phase 3 of epic #1384 (issue #9963), on top of Phase 2 attach (#9962, PR #10719):

  • Supervised stdio by default. Extras.Supervised is now a *bool; parse materializes the default (true) for stdio servers in file-loaded configs, and "supervised": false is the opt-out into the legacy direct-spawn path. Aliases inherit only the supervised bit from their target — per-view extras (e.g. excludeTools) stay the alias's own. SupervisedEnabled() reads the resolved value; programmatically built configs keep the Phase 1 explicit opt-in.
  • Restart through the supervisor. The supervisor protocol gains restart and terminate handshake actions. RestartSupervised has the supervisor kill and respawn its child and attaches the requester to the new child (new PID; supervisor and socket survive). Pool.Restart uses it for supervised pools with no busy instances; busy instances keep the generic drain path.
  • Adopt-or-reap scan. mcpclient.ScanSupervisorSockets runs at daemon startup (via Registry.ReapOrphanedSupervisors, after the Phase 2 adoption scan): configured supervisors are left for adoption, orphaned supervisors are reaped via the terminate action with the reap logged, refusals (attached / version mismatch) are logged and left in place, stale socket files are removed.
  • Protocol refusal in status. A protocol-version refusal during adoption is recorded as the pool's last error, so mcpx status names it; mcpclient.IsProtocolRefusal classifies both refusal spellings.
  • Test-binary re-exec guard. testsupport.SuperviseReExec is wired into the pool and daemon test mains: with supervised as the default, a suite that dials stdio re-execs its own binary as the supervisor, and without the guard that re-exec runs the whole suite recursively.

Acceptance (#9963)

  • Fresh daemon start with default config runs stdio servers supervised — TestDefaultConfigStdioRunsSupervised (load file → resolve → acquire → supervisor socket + child PID), plus TestSupervisedDefaultsOnForStdioFromFile for the opt-out.
  • Adopt-or-reap scan covered for both branches — TestScanSupervisorSocketsAdoptAndReap (configured/adopt, orphan reap with log, stale removal).
  • Status names a supervisor protocol-version refusal — TestAdoptProtocolRefusalSurfacesInStatus + TestSupervisorProtocolRefusalIsClassified.
  • mcpx: takeover/upgrade/handoff unsupported on darwin; Linux-only tests break the darwin build #237 darwin skip list shrinks to legacy-handoff only — not in this PR: all four affected test packages now cross-compile for darwin/arm64 (go vet with GOOS=darwin, verified), but unskipping the takeover tests needs a darwin runner to prove they pass at runtime; this lane has no darwin machine. Recorded on mcpx: Phase 3 of #1384 — supervised stdio by default + lifecycle hygiene #9963 as the remaining item.

Tests

On the laptop, against this branch (rebased on current main):

  • go test ./internal/config/ ./internal/mcpclient/ ./internal/pool/ ./internal/daemon/ ./internal/buildcheck/ ./internal/testsupport/ — all pass.
  • go test ./internal/e2e/ -run TestTakeoverAttachesToSupervisedChild — passes.
  • New tests: restart changes the child PID and keeps echo working (TestSupervisedRestartThroughSupervisor), terminate reaps the child and removes the socket (TestSupervisedTerminateReapsChild).

Task 17484, lane any-d.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…ough supervisor (#9963)

Phase 3 of #1384 (issue #9963), on top of Phase 2 attach (#9962):

- Supervised is now a *bool; parse materializes the default (true)
  for stdio servers in file-loaded configs, with supervised:false
  as the opt-out into the legacy direct-spawn path. Aliases inherit
  only the supervised bit from their target (per-view extras like
  excludeTools stay the alias's own). SupervisedEnabled reads the
  resolved value; programmatically built configs keep Phase 1
  explicit opt-in.
- Supervisor protocol gains restart and terminate actions.
  RestartSupervised has the supervisor kill and respawn its child
  and attaches the requester to the new child; Pool.Restart uses it
  for supervised pools with no busy instances. Terminate is the
  reap mechanism: it refuses while a daemon is attached.
- Adopt-or-reap scan (mcpclient.ScanSupervisorSockets): at daemon
  startup, configured supervisors are left for the Phase 2 adoption
  scan, orphaned supervisors are reaped with the reap logged,
  refusals are logged and left in place, stale socket files are
  removed. Registry.ReapOrphanedSupervisors wires it into Listen.
- A protocol-version refusal during adoption is recorded as the
  pool's last error, so mcpx status names it (with
  mcpclient.IsProtocolRefusal classifying both refusal spellings).
- Test binaries that dial stdio through pools (pool, daemon) handle
  the supervisor re-exec via testsupport.SuperviseReExec: without
  it the re-exec runs the whole suite as the supervisor.

Tests: config default + opt-out, pool fresh-daemon acceptance
(default config acquires supervised, socket present), adoption
refusal surfacing in Status().LastError, restart changes the child
PID and keeps working, terminate reaps the child and removes the
socket, scan adopt/reap/stale branches, protocol refusal
classification. Suites green: config, mcpclient, pool, daemon,
buildcheck, testsupport; e2e supervised takeover test passes.

Darwin (#237): all four affected test packages now cross-compile
for darwin/arm64 (go vet GOOS=darwin), but the package.nix
darwinSkip runtime list is unchanged in this PR: shrinking it
needs a darwin runner to verify the takeover tests actually pass
there, which this change does not have. Recorded on #9963.
@dezren39
dezren39 requested a review from a team as a code owner November 16, 2026 13:51
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-16T13:51:28.352765Z
We couldn’t complete this review. Comment @codex review to try again.
0a5b9e0 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 19 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2fcc83d2-b7e0-413d-9018-a0388bee8f2e
Commits

Reviewing files that changed from the base of the PR and between d644088 and 0a5b9e0.

Files selected for processing: 13

  • pkgs/mcpx/internal/config/config.go
  • pkgs/mcpx/internal/config/supervised_default_test.go
  • pkgs/mcpx/internal/daemon/main_test.go
  • pkgs/mcpx/internal/daemon/registry_handoff.go
  • pkgs/mcpx/internal/daemon/server.go
  • pkgs/mcpx/internal/mcpclient/supervised.go
  • pkgs/mcpx/internal/mcpclient/supervised_phase3_test.go
  • pkgs/mcpx/internal/mcpclient/supervised_scan.go
  • pkgs/mcpx/internal/pool/handoff.go
  • pkgs/mcpx/internal/pool/main_test.go
  • pkgs/mcpx/internal/pool/pool.go
  • pkgs/mcpx/internal/pool/supervised_default_test.go
  • pkgs/mcpx/internal/testsupport/supervise.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@dezren39

Copy link
Copy Markdown
Member Author

agent-note:v1
state: merge_ready
task: 17484
lane: any-d

Codex gate disposition: the Codex review run on this PR failed on Codex usage limits ("You have reached your Codex usage limits for code reviews") and produced no findings — pulls/10767/comments is empty and there are no review threads to disposition. CodeRabbit is likewise rate-limited. There is nothing substantive to fix or reply to; merging under the standing criteria on local verification instead: config, mcpclient, pool, daemon, buildcheck, testsupport suites all pass on this branch (rebased on current main), and the e2e supervised takeover test passes. CI runs on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant